<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>${name_china}管理列表</title>
<%@include file="/common/head.jsp" %>

<!-- 时间日期插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/My97DatePicker/skin/default/datepicker.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
#table td,#table th{
	border:1px solid #ccc;
	padding:1% 1%;
	text-align:center

}
.summer-datagrid-cell{
	text-align:center;
}
.top-batch{
    height: 64px;
    text-align: center;
    border: 1px solid rgba(121, 121, 121, 1);
    line-height: 64px;
}

</style>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>设置推广位</span>
            <a id="goBack" class="distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
        </div>
        <div id="toolbar"  style="float: right">
	          
        </div>
    </div>
    <div class="page-title-border"></div>
</div>
<div>
	<table class="summer-datagrid" style="width:auto">
	    <thead class="orderhead">
	    	<tr>
	    		<th style="width:200px;background-color: rgba(22, 155, 213, 1);" ><div class="top-batch">已选推广用户</div></th>
	    		<th  style="width:200px;"><div class="top-batch"><a id="allTgw" href="javascript:;">全部推广用户</a></div></th>
	    	</tr>
	    </thead>		
	</table>
</div>
</div>

<div class="search-field">
    <!-- <span class="field-cont">
        <span class="field-cont-title">累计订单:</span>
         <input type="text" class="summer-input" id=""/>
    </span>
   <span class="field-cont">
        <span class="field-cont-title">有效累计订单:</span>
         <input type="text" class="summer-input" id=""/>
   </span>
    
    <span class="field-cont">
        <span class="field-cont-title">累计总额:</span>
         <input type="text" class="summer-input" id=""/>
    </span>
    <span class="field-cont">
        <span class="field-cont-title">累计建群数:</span>
         <input type="text" class="summer-input" id=""/>
    </span>
    <span class="field-btn-wrapper">
        <a id="search" class="btn btn-primary btn-icon wave distance-right"><i class="icon icon-search"></i></a>
        <a id="reset" class="btn btn-icon wave wave-dark"><i class="icon icon-refresh"></i></a>
    </span> -->
    
</div>

<div id="t-wrap">
    <table class="summer-datagrid" id="dataList">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	  
	    <thead>
		    <tr>
		        <th>推广位Id</th>
				<th>用户Id</th>
		        <th>用户名称</th>
		        <th>群主手机号</th>
		        <th>操作</th>
		    </tr>
	    </thead>
    </table>
</div>

<script>
	//请求url
	var CONST_URL = {
		INIT:basePath + '${common_url}init',
		LIST: basePath + '${common_url}userTgw/list',
		DEL: basePath + '${common_url}userTgw/del',
		INIT_MAIN: basePath + "${common_url}initPerform?id=${groupId}",
		TGW_PERFORM_VIEW : basePath + '${common_url}TgwPerformView'
	};
    var  permission = CommonUtil.getPermission('${name_english}');
    $(function () {
       createTable();
    // 重新加载表格
		function reloadTable() {
			$('#dataList').datagrid('reload',{
	            ajax: {
	            	param: {
	            		"fullName": trimSpace($('#fullName').val()),
	                	"buyStartTime": trimSpace($('#buyStartTime').val()),
	                	"buyStopTime": trimSpace($('#buyStopTime').val())
	            	}
	            }
	        });
		}
		$('#backBtn,#goBack').on('click',backMain);
	    function backMain() {
	    	window.location.href = CONST_URL.INIT_MAIN;
	    }
	    $('#t-wrap').on('click', 'a[data-permit="${name_english}:tgwPerform"]', function() {
            var $this = $(this),
                id = $this.closest('tr').find('td[data-field="id"]').attr('data-value');
            window.location.href = CONST_URL.TGW_PERFORM_VIEW + '?id=' + id+"&groupId=${groupId}&userId=${userId}";
        });
	    $('#t-wrap').on('click', 'a[data-permit="${name_english}:delTgw"]', function() {
			var $this = $(this),
			    id = $this.closest('tr').find('td[data-field="id"]').attr('data-value');
			$.sdialog({
				type: 'confirm',
				msg: '您确定要删除选中的记录吗?',
				onConfirm: function(result) {
				    if (result) {
				    	$.sajax({
			                url : CONST_URL.DEL + "?id=" + id,
			                onLoadSuccess : function() {
			                	 $.stip({
                	                type:'ok',//显示类型 有info、 ok、 danger
                	                text: '删除成功！'    
			                	});
			                	reloadTable();  
			                }
			            });
				    		
				    }	
				}
			});
		});
	    //创建表格
	    function createTable() {
	    	$('#dataList').datagrid({
	    		ajax: {
	    			url: CONST_URL.LIST,
	    			param: {
	    				"userId": ${userId}
	            	} 
	    		},
	    		columns: [
	    		     {
	    		    	 field: 'id',
	    		    	 hidden: true
	    		     },
	    		     {
	    		    	 field: 'tgw',
	    		    	
	    		     },
	    		     {
	    		    	 field: 'yunId',
	    		     },{
	    		    	 field: 'name',
	    		     },{
	    		    	 field: 'phone',
	    		     },
	    		     {
	    		    	 render: function (rowData) {
	    		    		 return $.funcbar({
	    		    			 data: permission,    //请求的数据
	    		    			 type: 'text',     //类型
	    		    			 display: 2,    //显示数量
	    		    			 permit: ['${name_english}:delTgw','${name_english}:tgwPerform'] //需要的权限按钮
	    		    		 });
	    		    	 }
	    		    }
	    		    
	    		          
	    	    ]
	    	});
	    }
    });
</script>
</body>
</html>